﻿myApp.controller("AddReviewCtrl", ['$scope', '$http', '$routeParams', '$restUrls', '$post', '$rootScope', function ($scope, $http, $routeParams, $restUrls, $post, $rootScope) {
    var product_id = $routeParams.id;
    $scope.SaveReview = function (data) {
        if ($scope.AddReviewForm.$valid) {
            var parameters = {
                product_id: product_id,
                text: data.text,
                rating: 5
            }
            $post($restUrls["addReview"], parameters).success(function (result) {
                if (result.success == 1) {
                    window.history.back();
                } else {
                    $.scojs_message(result.message, $.scojs_message.TYPE_ERROR);
                }
            });
        }
        else {
            $scope.showOneError = true;
        }
    }
    ShareOnWx("『新品上市』", "零食4.0——川西新派冷吃兔 私厨珍藏配方160g",  "http://haichi.cc/www/index.html#/product/50", "http://haichi.cc/www/img/cp1.jpg");
}]);